package reviewAlgorithms.greedyThought;

import java.util.Arrays;

public class AssignCookies {
    public static void main(String[] args) {
        int[] g = {10,9,8,7};
        int[] s = {5,6,7,8};
        Arrays.sort(g);
        Arrays.sort(s);
        System.out.println(findContentChildren(g,s));
    }
    public static int findContentChildren(int[] g, int[] s) {
        if (s == null || g == null || s.length < 1 || g.length < 1){
            return 0;
        }
        int count = 0;
        int i = 0;
        int j = 0;
        while (i < s.length && j < g.length){
            if (s[i] >= g[j]){
                count ++;
                j ++;
            }
            i ++;
        }
        return count;
    }
}
